//
//  MyBtton.m
//  福意商城商家端
//
//  Created by admin on 2019/12/12.
//  Copyright © 2019 admin. All rights reserved.
//

#import "MyBtton.h"

@implementation MyBtton

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
    CGRect bounds = self.bounds;
    CGFloat widthDelta = MAX(self.touchSize.width - bounds.size.width, 0);
    CGFloat heightDelta = MAX(self.touchSize.height - bounds.size.height, 0);
    CGRect NewBounds = CGRectInset(bounds, -0.5*widthDelta, -0.5*heightDelta);
    return CGRectContainsPoint(NewBounds, point);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    if (_title_w == 0) {
        contentRect = (CGRect){{0,0},{self.frame.size.width,self.frame.size.height}};
    }else{
        contentRect = (CGRect){{_title_x,_title_y},{_title_w,_title_h}};
    }
    return contentRect;
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    if (_image_w == 0) {
        contentRect = (CGRect){{0,0},{self.frame.size.width,self.frame.size.height}};
    }else{
        contentRect = (CGRect){{_image_x,_image_y},{_image_w,_image_h}};
    }
    
    return contentRect;
}


@end
